package com.ls.lserp.modules.material.service;

import com.ls.lserp.common.persistence.Page;
import com.ls.lserp.common.service.CrudService;
import com.ls.lserp.modules.material.dao.InventoryClothesDetailDao;
import com.ls.lserp.modules.material.dao.SlopworkStockDao;
import com.ls.lserp.modules.material.entity.InventoryClothesDetail;
import com.ls.lserp.modules.material.entity.SlopworkStock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zhouyang on 2017/12/8.
 */
@Service
@Transactional(readOnly = false)
public class SlopworkStockService  extends CrudService<SlopworkStockDao,SlopworkStock> {
    @Autowired
    private  SlopworkStockDao slopworkStockDao;
    @Autowired
    private InventoryClothesDetailDao  inventoryClothesDetailDao;
    /**
     * @Title: findList
     * @Description: 一览查询;
     * @param page
     * @param slopworkStock
     * @return Page<SlopworkStock>
     */
    public Page<SlopworkStock> findList(Page<SlopworkStock> page, SlopworkStock slopworkStock) {
        // 设置分页参数
        slopworkStock.setPage(page);
        // 执行分页查询
        page.setList(slopworkStockDao.findList(slopworkStock));
        return page;
    }
   public  InventoryClothesDetail findInOutDetail(InventoryClothesDetail inventoryClothesDetail){
       //根据styleId获取款式基本信息
       inventoryClothesDetail = inventoryClothesDetailDao.get(inventoryClothesDetail.getStyleId());
       //实际库存
       List<InventoryClothesDetail>  sizeList = inventoryClothesDetailDao.getSizeListByStyleId(inventoryClothesDetail);
       //出入库明细
       List<InventoryClothesDetail>  detailsList = inventoryClothesDetailDao.getSizeDetailListByStyleId(inventoryClothesDetail);
       inventoryClothesDetail.setSizeList(sizeList);
       inventoryClothesDetail.setSizeDetailsList(detailsList);
       return  inventoryClothesDetail;
   }
}
